﻿<%@ Page Title="" Language="C#" MasterPageFile="~/App_MasterPages/MainMasterPage.master"
    AutoEventWireup="true" CodeFile="CategoryItem.aspx.cs" Inherits="Admin_CategoryItem" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Main_HeaderContentPlaceHolder" runat="Server">
    <script type="text/javascript">
        function Mandatory(sender, e) {
            e.IsValid = (e.Value != '0');
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Main_MainContentPlaceHolder" runat="Server">
    <div id="background-blue2">
        background
    </div>
    <div class="page">
        <div class="page2">
            <div class="sidebar">
                <a href="../Default.aspx" id="logo">
                    <img id="Img1" runat="server" src="~/App_Themes/Default/images/logo.png" alt="logo" /></a>
                <ul>
                    <li class="home">
                        <a id="default_a" href="~/Admin/Confirm.aspx" runat="server">آزمایشات تایید شده</a></li>

                    <li class="selected about">
                        <a id="testlist_a" href="~/Admin/CategoryItem.aspx" runat="server">گروه آزمایشات</a></li>

                    <li class="projects">
                        <a id="paper_a" href="#" runat="server">کاربری</a></li>
                    <li class="blog">
                        <a id="gallery_a" href="#" runat="server">مدیریت سایت</a></li>

                    <li class="contact">
                        <a id="logout_a" href="#" runat="server" onclick="if(!confirm('آیا قصد خروج از سیستم را دارید؟')) return false;" onserverclick="LogoutButton_Click">خروج از سیستم</a></li>
                </ul>
            </div>
            <div class="body">
                <div>
                    <asp:MultiView ID="MultiView" runat="server" ActiveViewIndex="0">
                        <asp:View ID="ShowView" runat="server">
                            <table style="width: 100%;">
                                <tr style="color: #FFFFFF;">
                                    <td>گروه آزمایش:
                                    </td>
                                    <td style="width: 250px">
                                        <asp:TextBox ID="CategoryTextBox" runat="server" Width="200px"></asp:TextBox>
                                    </td>
                                    <td>سایز صفحه:
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="PageSizeDropDownList" SkinID="SearchDropDownList" runat="server">
                                            <asp:ListItem Selected="True" Value="5">[پیش فرض]</asp:ListItem>
                                            <asp:ListItem Value="5">5 رکورد</asp:ListItem>
                                            <asp:ListItem Value="10">10 رکورد</asp:ListItem>
                                            <asp:ListItem Value="15">15 رکورد</asp:ListItem>
                                            <asp:ListItem Value="20">20 رکورد</asp:ListItem>
                                            <asp:ListItem Value="25">25 رکورد</asp:ListItem>
                                            <asp:ListItem Value="1000000">تمام رکورد ها</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                    <td>
                                        <asp:ImageButton ID="SearchImageButton" runat="server" OnClick="SearchImageButton_Click"
                                            SkinID="SearchButton" />
                                        <asp:ImageButton ID="ClearImageButton" runat="server" OnClick="ClearImageButton_Click"
                                            OnClientClick="return false;" SkinID="ClearButton" />
                                    </td>
                                </tr>
                                <tr align="center">
                                    <td colspan="5">
                                        <table>
                                            <tr>
                                                <td align="center" valign="middle">
                                                    <asp:GridView ID="CategoryGridView" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                                        DataKeyNames="CategoryID" DataSourceID="CategoryEntityDataSource" HorizontalAlign="Center"
                                                        OnSelectedIndexChanged="CategoryGridView_SelectedIndexChanged" Width="100%" PageSize="5">
                                                        <Columns>
                                                            <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" ReadOnly="True" Visible="false"
                                                                SortExpression="CategoryID" />
                                                            <asp:TemplateField>
                                                                <ItemTemplate>
                                                                    <asp:ImageButton ID="SelectImageButton" runat="server" CommandName="Select" SkinID="SelectButton" />
                                                                </ItemTemplate>
                                                                <ItemStyle Width="25px" />
                                                            </asp:TemplateField>
                                                            <asp:BoundField DataField="CategoryTitle" HeaderText="عنوان گروه" ReadOnly="True"
                                                                SortExpression="CategoryTitle">
                                                                <ItemStyle Width="300px" />
                                                            </asp:BoundField>
                                                            <asp:BoundField DataField="Description" HeaderText="توضیحات" ReadOnly="True" SortExpression="Description">
                                                                <ItemStyle Width="450px" />
                                                            </asp:BoundField>
                                                        </Columns>
                                                    </asp:GridView>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </asp:View>
                        <asp:View ID="EditView" runat="server">
                            <table>
                                <tr style="color: #FFFFFF">
                                    <td style="width: 450px">عنوان گروه آزمایش:
                        <asp:Label ID="CategoryLabel" runat="server" Text=""></asp:Label>
                                    </td>
                                    <td></td>
                                    <td style="text-align: center; width: 450px">
                                        <asp:LinkButton ID="ReturnLinkButton" runat="server" OnClick="ReturnLinkButton_Click">بازگشت</asp:LinkButton>
                                    </td>
                                </tr>
                                <tr>
                                    <td valign="top" style="width: 450px">
                                        <asp:GridView ID="CategoryItemGridView" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                            DataKeyNames="CategoryItemID" DataSourceID="CategoryItemEntityDataSource" HorizontalAlign="Center"
                                            OnSelectedIndexChanged="CategoryItemGridView_SelectedIndexChanged" Width="100%"
                                            AllowSorting="True" PageSize="5">
                                            <Columns>
                                                <asp:TemplateField>
                                                    <ItemTemplate>
                                                        <asp:ImageButton ID="SelectImageButton" runat="server" CommandName="Select" SkinID="SelectButton" />
                                                    </ItemTemplate>
                                                    <ItemStyle Width="25px" />
                                                </asp:TemplateField>
                                                <asp:BoundField DataField="CategoryItemID" HeaderText="CategoryItemID" ReadOnly="True"
                                                    SortExpression="CategoryItemID" Visible="false" />
                                                <asp:BoundField DataField="CategoryItemTitle" HeaderText="عنوان آزمایش" SortExpression="CategoryItemTitle" />
                                                <asp:BoundField DataField="Description" HeaderText="توضیحات" SortExpression="Description" />
                                            </Columns>
                                        </asp:GridView>
                                    </td>
                                    <td style="width: 20px"></td>
                                    <td style="width: 450px" valign="top">
                                        <asp:FormView ID="CategoryItemFormView" runat="server" DataSourceID="CategoryItemEntityDataSource"
                                            DataKeyNames="CategoryItemID" DefaultMode="Insert" OnItemCommand="CategoryItemFormView_ItemCommand"
                                            Width="100%">
                                            <EditItemTemplate>
                                                <table border="0" cellpadding="0" cellspacing="0">
                                                    <tr valign="middle">
                                                        <td style="width: 100px" align="right">عنوان آزمایش :
                                                        </td>
                                                        <td style="width: 400px" align="right">
                                                            <asp:TextBox  ID="TitleTextBox" runat="server" Text='<%# Bind("CategoryItemTitle") %>'
                                                                MaxLength="500" Width="350px" />
                                                            <asp:RequiredFieldValidator ID="TitleRequiredFieldValidator" runat="server" ControlToValidate="TitleTextBox"
                                                                Display="Dynamic" ErrorMessage="*" ValidationGroup="Update"></asp:RequiredFieldValidator>
                                                            <asp:HiddenField ID="CategoryIDHiddenField" runat="server"
                                                                Value='<%# Bind("CategoryID") %>' />
                                                        </td>
                                                    </tr>
                                                    <tr valign="middle">
                                                        <td style="width: 80px" align="right">توضیحات آزمایش :
                                                        </td>
                                                        <td align="right" dir="rtl">
                                                            <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'
                                                                TextMode="MultiLine" MaxLength="2500" Height="150px" Width="350px" />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2" align="left">
                                                            <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
                                                                <tr>
                                                                    <td style="height: 15px"></td>
                                                                    <td align="left" valign="top" style="width: 80px;"></td>
                                                                    <td align="left" valign="top" style="width: 80px;"></td>
                                                                </tr>
                                                                <tr>
                                                                    <td style="height: 15px">&nbsp;
                                                                    </td>
                                                                    <td align="left" valign="top" style="width: 80px">
                                                                        <asp:ImageButton ID="DeleteImageButton" runat="server" CausesValidation="False" CommandName="Delete"
                                                                            SkinID="DeleteButton" OnClientClick="if (!confirm('آيا از حذف مطمئن هستيد؟')) return false;" />
                                                                    </td>
                                                                    <td align="left" valign="top" style="width: 80px">
                                                                        <asp:ImageButton ID="UpdateImageButton" runat="server" CommandName="Update" SkinID="UpdateButton"
                                                                            ValidationGroup="Update" OnClientClick="if (!confirm('آيا از اعمال تغییرات مطمئن هستيد؟')) return false;" />
                                                                    </td>
                                                                    <td align="left" valign="top" style="width: 80px">
                                                                        <asp:ImageButton ID="CancelImageButton" runat="server" CommandName="Cancel" SkinID="CancelButton" />
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </EditItemTemplate>
                                            <InsertItemTemplate>
                                                <table border="0" cellpadding="0" cellspacing="0" style="width: 500px">
                                                    <tr valign="middle">
                                                        <td style="width: 100px" align="right">عنوان آزمایش :
                                                        </td>
                                                        <td style="width: 400px" align="right">
                                                            <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("CategoryItemTitle") %>'
                                                                MaxLength="500" Width="350px" />
                                                            <asp:RequiredFieldValidator ID="TitleRequiredFieldValidator" runat="server" ControlToValidate="TitleTextBox"
                                                                Display="Dynamic" ErrorMessage="*" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                                                            <asp:HiddenField ID="CategoryIDHiddenField" runat="server"
                                                                Value='<%# Bind("CategoryID") %>' />
                                                        </td>
                                                    </tr>
                                                    <tr valign="middle">
                                                        <td style="width: 100px" align="right">توضیحات :
                                                        </td>
                                                        <td align="right" dir="rtl">
                                                            <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'
                                                                TextMode="MultiLine" MaxLength="2500" Height="150px" Width="350px" />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2" align="left">
                                                            <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
                                                                <tr>
                                                                    <td style="height: 15px">&nbsp;
                                                                    </td>
                                                                    <td align="left" valign="top" style="width: 80px;"></td>
                                                                    <td align="left" valign="top" style="width: 80px;"></td>
                                                                </tr>
                                                                <tr>
                                                                    <td style="height: 15px">&nbsp;
                                                                    </td>
                                                                    <td align="left" valign="top" style="width: 80px;">
                                                                        <asp:ImageButton ID="InsertButton" runat="server" CommandName="Insert" SkinID="InsertButton"
                                                                            ValidationGroup="Insert" OnClick="InsertButton_Click" />
                                                                    </td>
                                                                    <td align="left" valign="top" style="width: 80px;">
                                                                        <asp:ImageButton ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                                                            SkinID="CancelButton" />
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </InsertItemTemplate>
                                        </asp:FormView>
                                    </td>
                                </tr>
                            </table>
                        </asp:View>
                    </asp:MultiView>
                    <asp:HiddenField ID="CategoryIDHiddenField" runat="server" />
                    <asp:EntityDataSource ID="CategoryEntityDataSource" runat="server" ConnectionString="name=DefaultEntityConnection"
                        DefaultContainerName="DefaultEntityConnection" OrderBy="it.[CategoryTitle]" EntitySetName="Categories"
                        Select="it.[CategoryID], it.[CategoryTitle], it.[Description]" Where="(@CategoryTitle is null || it.CategoryTitle LIKE '%' + @CategoryTitle + '%')"
                        EnableFlattening="False">
                        <WhereParameters>
                            <asp:ControlParameter ControlID="CategoryTextBox" Name="CategoryTitle" Type="String" />
                        </WhereParameters>
                    </asp:EntityDataSource>
                    <asp:EntityDataSource ID="CategoryItemEntityDataSource" runat="server" ConnectionString="name=DefaultEntityConnection"
                        DefaultContainerName="DefaultEntityConnection" EnableDelete="True" EnableInsert="True"
                        EnableUpdate="True" EntitySetName="CategoryItems" OnDeleted="CategoryItemEntityDataSource_Command"
                        OnInserted="CategoryItemEntityDataSource_Command" OnUpdated="CategoryItemEntityDataSource_Command"
                        Where="it.Category.CategoryID = @CategoryID" Include="Category" EnableFlattening="False">
                        <WhereParameters>
                            <asp:ControlParameter ControlID="CategoryIDHiddenField" DbType="Int32" Name="CategoryID"
                                PropertyName="Value" DefaultValue="0" />
                        </WhereParameters>
                    </asp:EntityDataSource>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
